<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : DetailedLesson_admin.xsl
    Created on : July 15, 2013, 3:38 PM
    Author     : NamDH
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:detail="http://xml.netbeans.org/schema/DetailedLessions"
                xmlns:lessonlist="http://xml.netbeans.org/schema/lessonList">
    <xsl:output method="html" encoding="UTF-8" />
    <xsl:param name="lId"/>
    <xsl:param name="lessonlist"/>
    <xsl:param name="type"/>
    <xsl:variable name="lessonlistdoc" select="document($lessonlist)"/>

    <!-- TODO customize transformation rules
         syntax recommendation http://www.w3.org/TR/xslt
    -->
    <xsl:template match="/">
        <html>
            <body>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="detail:DetailedLessons">
        <xsl:variable name="count">
            <xsl:value-of select="count(detail:DetailedLesson)"/>
        </xsl:variable>
        <div id="page">
            <div id="wrap" class="divwraphead">
                <div id="top">
                    <div id="N_title">
                        <div id="left-title">
                        </div>
                        <div id="right-title" style="">
                            <div id="text-right-title">Tên bài</div>
                        </div>
                        <div id="lessonName">
                            <xsl:value-of select="$lessonlistdoc//lessonlist:lessonList[lessonlist:lessonId=$lId]/lessonlist:lessonName"/>
                            <xsl:if test="not ($type = 0)">
                                <xsl:choose>
                                    <xsl:when test="$type='tuvung'">
                                        <xsl:text>(TỪ VỰNG)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='nguphap'">
                                        <xsl:text>(NGỮ PHÁP)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='luyendoc'">
                                        <xsl:text>(LUYỆN ĐỌC)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='hoithoai'">
                                        <xsl:text>(HỘI THOẠI)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='luyennghe'">
                                        <xsl:text>(LUYỆN NGHE)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='baitap'">
                                        <xsl:text>(BÀI TẬP)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='hantu'">
                                        <xsl:text>(HÁN TỰ)</xsl:text>
                                    </xsl:when>
                                    <xsl:when test="$type='luyentap'">
                                        <xsl:text>(LUYỆN TẬP)</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise></xsl:otherwise>
                                </xsl:choose>
                            </xsl:if>
                        </div>
                    </div>
                </div>
                <div id="mid">
<!--                    <div style="margin: 10px">
                        <form>
                            <a href="#" class="changedoc_button">Change doc</a>
                         
                         <a href="#" class="download_button">Download</a>

                         <a href="#" class="delete_button">Delete</a>
                         </form>
                    </div>-->
                   
                    <div id="tabbed_section">
                         
                        <div id="menu">
                            <ul id="ul_tabs">
                                <xsl:for-each select="detail:DetailedLesson">
                                    <xsl:variable name="counter">
                                        <xsl:number value="position()"/>
                                    </xsl:variable>
                                    <li class="lh" id="t{$counter}" onClick="change('tab{$counter}')">
                                        <xsl:value-of select="detail:Part"/>
                                    </li>
                                </xsl:for-each>
                                <!-- 2 dong code ke tiep chua test -->
                                <li class="lh" id="t{$count + 1}" onClick="change('tab{$count + 1}')">Thêm thẻ
                                </li>
                            </ul>
                        </div>

                      

                        <input id="countvalue" name="countvalue" type="hidden" value="{$count}"/>

                        <div id="Display_content" onload="change('h1')">
                        </div>
                        <xsl:for-each select="detail:DetailedLesson">
                            <xsl:variable name="counter">
                                <xsl:number value="position()"/>
                            </xsl:variable>
                            <div id="tab{$counter}" class="content_tab">
                                
                                <xsl:value-of select="detail:Substance" disable-output-escaping="yes"/>
                                <br/>
                                <form action="ControllerServlet">
                                    <a href="#" class="delete_button" title="Delete">Delete</a>
                                    <a href="#" class="changedoc_button" title="Change Doc">Change Doc</a>
                                    <a href="#" class="download_button" title="Download">Download</a>
                                </form>
                            </div>
                        </xsl:for-each>
                        <div id="tab{$count + 1}" class="content_tab">
                            <form action="ControllerServlet" method="post" enctype="multipart/form-data">
                                <table border="0" width="445px" >
                                    <tbody>
                                        <tr>
                                            <td>Lesson ID:</td>
                                            <td name="lessonId" colspan="2">
                                                <xsl:value-of select="$lId"/>
                                            </td>
                                        </tr>
                                        <xsl:if test="not ($type = 0)">
                                            <tr>
                                                <td>Lesson Type</td>
                                                <td name="detailType">
                                                    <xsl:value-of select="$type"/>
                                                </td>
                                            </tr>
                                        </xsl:if>
                                        <xsl:if test="($type = 0)">
                                            <tr>
                                                <td>Lesson Type</td>
                                                <td>
                                                    <xsl:text>N/A</xsl:text>
                                                </td>
                                            </tr>
                                        </xsl:if>
                                        <tr>
                                            <td></td>
                                        </tr>
                                        <tr>
                                            <td width="110px">Tên thẻ:</td>
                                            <td colspan="2">
                                                <input type="text" name="txtNewTabName" value="" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="110px">Chọn file world:</td>

                                            <td colspan="2">
                                                <input id="txtFilePath" type="text" name="txtFilePath"
                                               onclick="callfileinput()" readonly="true" />
                                                <input type="button" value="Browse..."
                                   onclick="callfileinput()" />
                                                <input type="file" id="ifFilePath" onchange="printPath()"
                                   name="ifFilePath" value="" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword"
                                   style="visibility: hidden;" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <input type="submit" value="Add Tab" name="btAction" />
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>

<!--           Điền tên thẻ: <input type="text" name="txtNewTabName" value="" /> <br>-->
<!--           Chọn file world: <input type="file" name="ifFilePath" value="" /> <br>-->
<!--            <input type="submit" value="Add Tab" name="btAction" />-->
                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>